package com.glsc.ngateway.flowable.service.feignservice;

import com.glsc.ngateway.common.api.oaflow.dto.param.ParamOaLoginDto;
import com.glsc.ngateway.common.api.oaflow.feign.IFeignOaFlowService;
import com.glsc.ngateway.common.api.oaflow.resp.CommonResponse;
import com.glsc.ngateway.common.api.oaflow.resp.ResponseLoginDto;
import io.swagger.annotations.ApiParam;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Map;

@Service
public class OaflowFeignService {

    @Resource
    IFeignOaFlowService IFeignOaFlowService;

    public String endOaFlow(@RequestParam("requestId") String requestId) {
        return IFeignOaFlowService.endOaFlow(requestId);
    }

    public String createOaflow(@RequestBody Map<String, Object> dataMap, @RequestParam("flowId") String flowId) {
        return IFeignOaFlowService.createOaFlow(dataMap, flowId);
    }

    public CommonResponse<ResponseLoginDto> oaLogin(@RequestBody ParamOaLoginDto params) {
        return IFeignOaFlowService.oaLogin(params);
    }

    /*
     * 从网关获取OA流程PDF
     * */
    public ResponseEntity<byte[]> getOaFlowPdf(@ApiParam(required = true, value = "srcPath") String srcPath, @ApiParam(required = true, value = "sessionId") String sessionId) {
        return IFeignOaFlowService.getOaFlowPdf(srcPath, sessionId);
    }

    public String uploadDoc(@RequestPart(value = "file") MultipartFile[] file) {
        return IFeignOaFlowService.uploadDoc(file);
    }
}
